package com.atguigu.yygh.task.schedule;

import com.atguigu.yygh.rabbitmq.config.MQProperties;
import com.atguigu.yygh.rabbitmq.service.RabbitmqService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Author zhmwi
 * @Date 2021/7/27
 * @Dersciption
 */
@Component
@EnableScheduling
public class ScheduledTask {

    @Autowired
    private RabbitmqService rabbitmqService;

    /**
     * 每天8点执行 提醒就诊
     */
    //@Scheduled(cron = "0 0 8 * * ?")
    @Scheduled(cron = "0/10 * * * * ?")//每10s执行一次
    public void task1() {
        System.out.println(new Date().toLocaleString());
        rabbitmqService.sendMessage(MQProperties.EXCHANGE_DIRECT_TASK, MQProperties.ROUTING_TASK_8, "");
    }
}
